import Mock from 'mockjs'

let id = 1
let username = 'zzd'
// 接口地址
Mock.mock('http://localhost:3000/getNavMenu', () => {
  return {
    data: [
      {
        name: '主页', src: '/'
      },
      {
        name: '文章', src: '/articles'
      }
    ]
  }
})
Mock.mock('http://localhost:3000/getFooter', () => {
  return {
    data: [
      {
        name: '版权所有', src: 'http://localhost', text: "zzd"
      },
      {
        name: '发送邮件', src: '/article/list', text: "Email"
      }
    ]
  }
})
Mock.mock('http://localhost:3000/getLinks', () => {
  return {
    data: [
      {
        name: 'baidu', src: '#'
      },
      {
        name: 'souhu', src: '#'
      }
    ]
  }
})
Mock.mock('http://localhost:3000/getIndexPic', () => {
  return {
    data: [
      {
        img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fnewyx-img.577hau.cn%2Fupload%2Fgallery%2F20121122%2F13603934244.JPG&refer=http%3A%2F%2Fnewyx-img.577hau.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1665375873&t=b044cc8dabad26b5c086a1d48bf7794e',
        src: '#',
        title: "zzd"
      },
      {
        img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg1.doubanio.com%2Fview%2Fgroup_topic%2Fl%2Fpublic%2Fp481183788.jpg&refer=http%3A%2F%2Fimg1.doubanio.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1665375952&t=c92110c2ec13b28b0fa32a1c7715a177',
        src: '#', 
        title: "Email"
      },
      {
        img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2Fd2a70eb0ed1011dabdebd5006d9f2f4d64f1b14f.jpg&refer=http%3A%2F%2Fi0.hdslb.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1665377794&t=f37350c65f13b410139c4b3fc5242456',
        src: '#',
        title: 'LWH'
      },
      {
        img: 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcn.best-wallpaper.net%2Fwallpaper%2F2560x1440%2F1309%2FTV-anime-Naruto_2560x1440.jpg&refer=http%3A%2F%2Fcn.best-wallpaper.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1665377917&t=996e2d617b8e4c2c5413eb5205f23457',
        src: '#',
        title: '啦啦啦'
      }
    ]
  }
})
Mock.mock('http://localhost:3000/getNewArticle', () => {
  return {
    data: [
      {
        title: '新文章1号未上线',
        data: '',
        id: 0,
        show: 1
      },
      {
        title: '新文章2号未上线',
        data: '',
        id: 1,
        show: 1
      },
      {
        title: '新文章3号',
        data: '33333333',
        id: 2,
        show: 0
      },
      {
        title: '新文章4号',
        data: '44444444',
        id: 3,
        show: 1
      },
      {
        title: '新文章5号',
        data: '55555555',
        id: 4,
        show: 0
      }
    ]
  }
})
Mock.mock('http://localhost:3000/getHotArticle', () => {
  return {
    data: [
      {
        title: '热文章1号未上线',
        data: '',
        id: 0,
        view: 0
      },
      {
        title: '热文章2号未上线',
        data: '',
        id: 1,
        view: 0
      },
      {
        title: '热文章3号',
        data: '33333333',
        id: 2,
        view: 0
      },
      {
        title: '热文章4号',
        data: '44444444',
        id: 3,
        view: 0
      },
      {
        title: '热文章5号',
        data: '55555555',
        id: 4,
        view: 0
      }
    ]
  }
})
Mock.mock(`http://localhost:3000/getArticle/${id}`, () => {
  if (id === 1) {
    return {
      code: 0,
      data: [
        {
          title: '测试文字1',
          writer: 'admin1',
          text: '这是测试文字1号',
          type: 1,
          tag: [ 'js', 'node'],
          show: 1,
          time: '12312321233',
          a_id: 1,
          typename: '分类1号',
          data: '',
          like: 0,
          view: 0
        }
      ]
    }
  }
})
Mock.mock(`http://localhost:3000/getArticles`, () => {
    return {
      data: [
        {
          title: '新文章1号未上线',
          data: '',
          id: 0
        },
        {
          title: '新文章2号未上线',
          data: '',
          id: 1
        },
        {
          title: '新文章3号',
          data: '33333333',
          id: 2
        },
      ]
    }
})
Mock.mock(`http://localhost:3000/getArticleTalk/${id}`, () => {
  if (id === 1) {
    return {
      data: [
        {
          username: 'admin1', time: 124123213, talk: "这是第一次评论"
        },
        {
          username: 'admin2', time: 124123213, talk: "这是第2次评论"
        }
      ]
    }
  }
})
Mock.mock('http://localhost:3000/users/user/article/talk', 'post', () => {
  return {
    code: 0,
    message: '成功',
    data: []
  }
})
Mock.mock(`http://localhost:3000/users/user/info/${username}`, () => {
  return {
    code: 0,
    message: '',
    data: {
      nikename: 'zzd',
      age: '18',
      sex: '男',
      ip: '::1',
      username: 'admin1',
      login: 0
    }
  }
})
Mock.mock(`http://localhost:3000/users/user/changeInfo`, () => {
  return {
    code: 0,
    message: '修改成功',
    data: []
  }
})
Mock.mock(`http://localhost:3000/users/user/mail/${username}`,'post', () => {
  return {
    code: 0,
    message: '发送成功',
    data: []
  }
})
Mock.mock(`http://localhost:3000/users/user/mailsGet`, () => {
  return {
    code: 0,
    message: '',
    data: [
      {
        m_id: 1,
        users: [
          'admin1',
          'zzd'
        ]
      },
      {
        m_id: 2,
        users: [
          'admin2',
          'lwh'
        ]
      }
    ]
  }
})
Mock.mock(`http://localhost:3000/users/user/mailGetter/${id}`, () => {
  return {
    code: 0,
    message: '',
    data: [
      {
        toUser: 'admin',
        mail: [
          {
            text: '这是要发的内容',
            time: 1231321233,
            read: [
              '1'
            ]
          }
        ]
      }
    ]
  }
})
Mock.mock('http://localhost:3000/users/register', 'post', () => {
  return {
    code: 0,
    message: '成功',
    data: []
  }
})
Mock.mock('http://localhost:3000/users/login', 'post', () => {
  return {
    code: 0,
    message: '成功',
    data: {
      token: '123123123'
    }
  }
})
Mock.mock('http://localhost:3000/users/user/articleType', () => {
  return {
    code: 0,
    message: '成功',
    data: [
      {
        uid: 1,
        name: 'js'
      },
      {
        uid: 2,
        name: 'node'
      }
    ]
  }
})
let like = 1
Mock.mock(`http://localhost:3000/users/user/like/${id}/${like}`, () => {
  return {
    code: 0,
    message: '成功',
    data: []
  }
})
Mock.mock(`http://localhost:3000/users/user/save/${id}`, () => {
  return {
    code: 0,
    message: '成功',
    data: []
  }
})
Mock.mock(`http://localhost:3000/users/user/saveList`, () => {
  return {
    code: 0,
    message: '成功',
    data: [
      {
        time: 1231414,
        a_id: '1',
        title: '测试文字1'
      },
      {
        time: 12312414,
        a_id: '1',
        title: '测试文字2'
      }
    ]
  }
})
Mock.mock('http://localhost:3000/admin/setArticle', 'post', () => {
  return {
    message: 'success',
    data: []
  }
})
Mock.mock('http://localhost:3000/admin/showArticle', 'post', () => {
  return {
    message: 'success',
    data: []
  }
})
Mock.mock('http://localhost:3000/admin/setArticleType', 'post', () => {
  return {
    message: 'success',
    data: []
  }
})
Mock.mock('http://localhost:3000/admin/getAllUser', () => {
  return {
    message: 'success',
    data: [
      {
        username: 'admin1',
        login: 0,
        ip: '::1'
      },
      {
        username: 'zzd',
        login: 0,
        ip: '::2'
      },
      {
        username: 'lwh',
        login: 0,
        ip: '::3'
      },
      {
        username: 'ccc',
        login: 1,
        ip: '::4'
      }
    ]
  }
})
Mock.mock(`http://localhost:3000/admin/stopLogin/${id}`, () => {
  return {
    message: 'success',
    data: [
      {
        username: 'admin1',
        login: 0,
        ip: '::1'
      },
      {
        username: 'zzd',
        login: 0,
        ip: '::2'
      },
      {
        username: 'lwh',
        login: 0,
        ip: '::3'
      },
      {
        username: 'ccc',
        login: 1,
        ip: '::4'
      }
    ]
  }
})